using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DataAccess;
using Entity; 
namespace Business
{
    public class bProduct_Equipment
    {
        public static int insertProduct_Equipment(eProduct_Equipment product_equipment)
        {
            DBHelper dbh = new DBHelper();

            IList<SqlParameter> paramList = new List<SqlParameter>();
            SqlParameter pr = new SqlParameter("@EquipmentID", SqlDbType.Int);
            pr.Value = product_equipment.EquipmentID;
            paramList.Add(pr);

            pr = new SqlParameter("@productID", SqlDbType.Int);
            pr.Value = product_equipment.productID;
            paramList.Add(pr);

            pr = new SqlParameter("@Amount", SqlDbType.Int);
            pr.Value = product_equipment.Amount;
            paramList.Add(pr);
            int r = dbh.ExecuteNonQuery("insertProduct_Equipment", CommandType.StoredProcedure, paramList);
            dbh.CloseConnection();
            return r;
        }
        public static int deleteProduct_Equipment(int productID)
        {
            DBHelper dbh = new DBHelper();

            IList<SqlParameter> paramList = new List<SqlParameter>();
            SqlParameter pr = new SqlParameter("@productID", SqlDbType.Int);
            pr.Value = productID;
            paramList.Add(pr);


            int r = dbh.ExecuteNonQuery("deleteProduct_Equipment", CommandType.StoredProcedure, paramList);
            dbh.CloseConnection();
            return r;
        }

        public static DataTable getProduct_EquipmentByProductID (int productID)
        {
            DBHelper dbh = new DBHelper();

            IList<SqlParameter> paramList = new List<SqlParameter>();

            SqlParameter pr = new SqlParameter("@productID", SqlDbType.Int);
            pr.Value = productID;
            paramList.Add(pr);

            DataTable dt = dbh.ExecuteQueryDataTable("getProduct_EquipmentByProductID", CommandType.StoredProcedure, paramList);
            dbh.CloseConnection();
            return dt;
        }
    }
}
